package com.freesky.web.manager.controller;

import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.web.manager.service.ICacheService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Freesky
 */
@Api(description = "缓存管理")
@Controller
@RequestMapping("/cache")
public class CacheController {
    @Autowired
    private ICacheService  cacheService;

    @ApiOperation(value = "进入界面-首页缓存")
    @GetMapping( "/home/page")
    public String homePage() {
        return "cache/home";
    }
    @ApiOperation(value = "进入界面-其它缓存")
    @GetMapping( "/other/page")
    public String otherPage() {
        return "cache/other";
    }

    @ResponseBody
    @GetMapping(value = "/home/cache")
    @ApiOperation(value = "获取首页缓存")
    public JSONResponse getHomeCache() {
        return cacheService.getHomeCache();
    }

    @ResponseBody
    @GetMapping(value = "/home/update")
    @ApiOperation(value = "刷新首页缓存")
    public JSONResponse updateHomeCache() {
        return cacheService.updateHomeCache();
    }

    @ResponseBody
    @GetMapping(value = "/recommend/cache")
    @ApiOperation(value = "获取推荐板块缓存")
    public JSONResponse getRecommendCache() {
        return cacheService.getRecommendCache();
    }

    @ResponseBody
    @GetMapping(value = "/recommend/update")
    @ApiOperation(value = "刷新推荐板块缓存")
    public JSONResponse updateRecommendCache() {
        return cacheService.updateRecommendCache();
    }

    @ResponseBody
    @GetMapping(value = "/thank/cache")
    @ApiOperation(value = "获取捐赠板块缓存")
    public JSONResponse getThankCache() {
        return cacheService.getThankCache();
    }

    @ResponseBody
    @GetMapping(value = "/thank/update")
    @ApiOperation(value = "刷新捐赠板块缓存")
    public JSONResponse updateThankCache() {
        return cacheService.updateThankCache();
    }
}
